package org.dinqy.impl;

import org.dinqy.ClauseBeanFactory;
import org.dinqy.syntax.LimitOffset;

/**
 * @author armandino (at) gmail.com
 */
public class LimitOffsetNode<T> extends ResultListNode<T> implements LimitOffset<T> {

    LimitOffsetNode(ClauseNode<T> parent) {
        super(parent);
    }

    @Override
    public LimitOffset<T> limit(int value) {
        setClauseBean(ClauseBeanFactory.limit(value));
        return createSuccessor();
    }

    @Override
    public LimitOffset<T> offset(int value) {
        setClauseBean(ClauseBeanFactory.offset(value));
        return createSuccessor();
    }

    private LimitOffset<T> createSuccessor() {
        LimitOffsetNode<T> successor = new LimitOffsetNode<T>(this);
        setSuccessor(successor);
        return successor;
    }
}
